package phototagger.imgsim;

/** A container class that holds a coeffient along with its x and
    y position in the coeffient array. Implements Comparable
    so that Lists of Coeffients can be sorted 
    @see CoeffientList
**/
public class Coeffient implements Comparable {
	
    protected double value;
    protected int xpos;
    protected int ypos;
    
    /** Create a new Coeffient container.
	@param myValue the value of the wavelet coeffient
	@param myXpos the x position of the wavelet coeffient in the 2D
	array
	@param myYpos the y position of the wavelet coeffient in the 2D
	array.
    **/
    Coeffient(double myValue, int myXpos, int myYpos) {
	value = myValue;
	xpos = myXpos;
	ypos = myYpos;
    }
    
    /** Defined to implement java.lang.Comparable 
	@param o the Coeffient to compare to the current one
	@returns -1 if the value of this Coeffient is less than o.value,
	1 if the value of this Coeffient is greater than o.value, and 0
	if they are the same 
    **/
    public int compareTo(Object o) {
	double ovalue = ((Coeffient)o).value;
	if(Math.abs(this.value) > Math.abs(ovalue)) {
	    return 1;
	} else if(Math.abs(this.value) < Math.abs(ovalue)) {
	    return -1;
	} else {
	    return 0;
	}
    }
    
    /** Prints the value, xpos, and ypos of this Coeffient **/
    public String toString() {
	return "value = " + value + " xpos = " + xpos + " ypos = " + ypos;
    }
}
